#ifndef DEVICESMEMHEAP_H_INCLUDED
#define DEVICESMEMHEAP_H_INCLUDED

#include "stdint.h"


/* 字节对齐（至少要4字节对齐） */
#define MEM_HEAP_ROUNDUP_VALUE  8
/* 使x对n字节对齐 */
#define memHeapRoundUp(x, n)    (((x) + (n) - 1) & (~((n) - 1)))


typedef struct{
    uint32_t startAddr;
    uint32_t stopAddr;
}MemHeapType;


/* 模拟动态内存大小 */
#define DEVICES_MEM_LENGTH  (1024 * 2)

/* 动态内存头部信息 */
extern MemHeapType g_typeMemHeapHead;


void vMemHeapInit(void);
void vMemHeapCreate(MemHeapType *ptypeMemHanle, uint8_t *pucMemHeap, int32_t iLength);
void *pvMemHeapMalloc(MemHeapType *ptypeMemHanle, int32_t iSize);
void *pvMemHeapCalloc(MemHeapType *ptypeMemHanle, int32_t iNumber, int32_t iSize);
void *pvMemHeapRealloc(MemHeapType *ptypeMemHanle, void *pvMemAddr, int32_t iSize);
void vMemHeapFree(MemHeapType *ptypeMemHanle, void *pvMemAddr);

#endif // DEVICESMEMHEAP_H_INCLUDED
